/*
 * Copyright © 2020-2021 尛飛俠（Denvie） All rights reserved.
 */

package cn.denvie.springboot.freemarker.config;

import cn.denvie.springboot.freemarker.custom.RoleDirectiveModel;
import freemarker.template.TemplateModelException;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.boot.autoconfigure.freemarker.FreeMarkerProperties;
import org.springframework.context.annotation.Configuration;

import javax.annotation.PostConstruct;

/**
 * FreeMarkerConfig。
 *
 * @author Denvie
 * @date 2021/5/25
 * @since 1.0.0
 */
@Configuration
public class FreeMarkerConfig {
    @Autowired
    private freemarker.template.Configuration configuration;
    @Autowired
    private RoleDirectiveModel roleDirectiveModel;
    @Autowired
    private FreeMarkerProperties freeMarkerProperties;

    @PostConstruct
    public void setSharedVariable() throws TemplateModelException {
        configuration.setSharedVariable("role", roleDirectiveModel);
        System.out.println(freeMarkerProperties);
    }
}
